#!/bin/bash
cd `dirname $0`

usage() {
    echo "Usage: $0 [-t <service|debug>]" 1>&2;
    exit 1;
}

while getopts ":t:" o; do
    case "${o}" in
        t)
            t=${OPTARG}
            ((t == service || t == debug)) || usage
            ;;
        *)
            usage
            ;;
    esac
done
shift $((OPTIND-1))

fuser -k 8088/tcp

if [ -n "${t+x}" ] && [ "${t}" == "debug" ]; then
    java -Xdebug -Xrunjdwp:transport=dt_socket,address=10001,server=y -jar app/build/libs/app.jar --spring.profiles.active=dev --server.port=8088 ＆
    exit 1
fi
#sudo /etc/init.d/massage-chair-manager restart
/etc/init.d/massage_chair_manager restart
